<template>
  <div class="filter">
    <PcRadios
      type="tab-type"
      :radios="tabArr"
      :value="tabValue"
      @change="$emit('update:tabValue', $event)"
    />
    <div class="right" v-if="showType === 'home'">
      <div class="label">
        <span>筛选</span>
        <el-tooltip popper-class="filter-tips-tooltip" placement="bottom" effect="dark">
          <div slot="content" class="contents">
            <div class="contents-item" v-for="{ title, content } in config.filterTipsContent" :key="title">
              <div class="title">{{ title }}</div>
              <div class="content">{{ content }}</div>
            </div>
            <div class="line"></div>
            <div class="bottom"><span>趋势确定性：</span><img :src="label" alt="" /></div>
          </div>
          <img class="tips" :src="tips" alt="" v-defaultCover
        /></el-tooltip>
        ：
      </div>
      <PcRadios
        type="radio-type"
        :radios="radiaArr"
        :value="radioValue"
        color="#FFFFFF"
        @change="$emit('update:radioValue', $event)"
      />
      <div class="turnover" @click.stop="$emit('update:isShowTurnover', !isShowTurnover)">
        <img :src="isShowTurnover ? checked : unchecked" alt="" />
        <span :class="{ 'is-check': isShowTurnover }">显示成交额</span>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { BlockType } from '@/types/api';
import { radioNum, type Filter } from '@/types/filter.ts';
import config from '@/config/index.ts';
const { checked, unchecked, tips, label } = config.imgs;

withDefaults(
  defineProps<{
    tabValue: string;
    radioValue: string;
    isShowTurnover: boolean;
    showType: 'home' | 'history';
  }>(),
  {
    tabValue: '',
    radioValue: '',
    isShowTurnover: false
  }
);
interface Emits {
  (e: 'update:tabValue', value: BlockType): void;
  (e: 'update:radioValue', value: string): void;
  (e: 'update:isShowTurnover', value: boolean): void;
}
const emits = defineEmits<Emits>();

const tabArr: Filter[] = [
  {
    label: '全部',
    key: ''
  },
  {
    label: '行业',
    key: 'cn_industry'
  },
  {
    label: '概念',
    key: 'cn_concept'
  }
];

const radiaArr: Filter[] = [
  {
    label: '短期+中期+长期上榜',
    key: `${radioNum.short},${radioNum.medium},${radioNum.long}`
  },
  {
    label: '短期+中期上榜',
    key: `${radioNum.short},${radioNum.medium}`
  },
  {
    label: '短期+长期上榜',
    key: `${radioNum.short},${radioNum.long}`
  }
];

</script>

<style lang="less">
.filter-tips-tooltip {
  padding: 0 !important;
  .contents {
    box-sizing: border-box;
    width: 560px;
    height: calc(100vh - 90px);
    max-height: 448px;
    background: #484848;
    border-radius: 2px;
    padding: 12px 16px;
    overflow-y: auto;
    .contents-item {
      margin-bottom: 12px;
      .title {
        font-family: MicrosoftYaHeiUI-Bold;
        font-size: 14px;
        color: #f2f2f2;
        letter-spacing: 0;
        text-align: justify;
        line-height: 24px;
        font-weight: 700;
      }
      .content {
        font-family: MicrosoftYaHeiUI;
        font-size: 14px;
        color: #dcdcdc;
        letter-spacing: 0;
        text-align: justify;
        line-height: 24px;
        font-weight: 400;
        margin-top: 4px;
      }
    }
    .line {
      width: 100%;
      height: 1px;
      background-color: rgba(151, 151, 151, 0.3);
      margin-bottom: 14px;
    }
    .bottom {
      display: flex;
      align-items: center;
      span {
        font-family: MicrosoftYaHeiUI-Bold;
        font-size: 14px;
        color: #f2f2f2;
        letter-spacing: 0;
        line-height: 24px;
        font-weight: 700;
      }
      img {
        width: 88px;
        height: 24px;
        margin-left: 4px;
      }
    }
  }
}
</style>
<style scoped lang="less">
.filter {
  box-sizing: border-box;
  width: 100%;
  max-width: 1446px;
  display: flex;
  justify-content: space-between;
}
.right {
  display: flex;
  align-items: center;
  .label {
    display: flex;
    align-items: center;
    font-family: MicrosoftYaHeiUI;
    font-size: 14px;
    color: #828282;
    line-height: 18px;
    font-weight: 400;
    margin-right: 4px;
    img.tips {
      width: 12px;
      height: 12px;
      margin-left: 4px;
      margin-right: 2px;
      cursor: pointer;
    }
  }
  .turnover {
    display: flex;
    align-items: center;
    margin-left: 20px;
    cursor: pointer;
    img {
      width: 14px;
      height: 14px;
      margin-right: 5px;
    }
    span {
      font-family: MicrosoftYaHeiUI;
      font-size: 14px;
      color: #828282;
      line-height: 18px;
      font-weight: 400;
      &.is-check {
        color: #ffffff;
      }
    }
  }
}
</style>
